package com.camel.record.model;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.camel.core.entity.BasePaginationEntity;
import lombok.Data;

import java.io.Serializable;

/**
 *
 * @author 86183
 * @TableName cti_task
 */
@TableName(value ="cti_task")
@Data
public class CtiTask extends BasePaginationEntity implements Serializable {
    /**
     * 主键
     */
    @TableField(value = "id")
    private Integer id;

    @TableId(value = "taskid")
    private String taskid;

    /**
     * 是否AI
     */
    @TableField(value = "ai_flag")
    private String aiFlag;

    /**
     * AI话术名称
     */
    @TableField(value = "ro_name")
    private String roName;

    /**
     * 任务状态
     */
    @TableField(value = "task_status")
    private String taskStatus;

    /**
     * 最后启动时间
     */
    @TableField(value = "last_begin_time")
    private String lastBeginTime;

    /**
     * 外呼号码
     */
    @TableField(value = "called_number")
    private String calledNumber;

    /**
     * 外呼数
     */
    @TableField(value = "tot_cust")
    private String totCust;

    /**
     * 已呼数
     */
    @TableField(value = "tot_callsuc")
    private String totCallsuc;

    /**
     * 未呼数
     */
    @TableField(value = "tot_uncall")
    private String totUncall;

    /**
     * 未接数
     */
    @TableField(value = "tot_failure")
    private String totFailure;

    /**
     * 已接数
     */
    @TableField(value = "tot_success")
    private String totSuccess;

    /**
     * 转接数
     */
    @TableField(value = "tot_tocustomer")
    private String totTocustomer;

    /**
     * 已呼率
     */
    @TableField(value = "tot_callsuc_rate")
    private String totCallsucRate;

    /**
     * 未呼率
     */
    @TableField(value = "tot_uncall_rate")
    private String totUncallRate;

    /**
     * 已接通率
     */
    @TableField(value = "tot_success_rate")
    private String totSuccessRate;

    /**
     * 转接率
     */
    @TableField(value = "tot_tocustomer_rate")
    private String totTocustomerRate;

    /**
     * 命中率
     */
    @TableField(value = "hit_rate")
    private String hitRate;

    /**
     * 后处理时长
     */
    @TableField(value = "acw_time")
    private String acwTime;

    /**
     * 重拨次数
     */
    @TableField(value = "redial_times")
    private String redialTimes;

    /**
     * 重播间隔时长
     */
    @TableField(value = "min_redial_interval")
    private String minRedialInterval;

    /**
     * 最大振铃时长
     */
    @TableField(value = "max_ring_time")
    private String maxRingTime;

    /**
     * 第三方校验URL
     */
    @TableField(value = "xintf")
    private String xintf;

    /**
     * 问卷ID
     */
    @TableField(value = "survey_id")
    private Integer surveyId;

    /**
     * 所属公司
     */
    @TableField(value = "company_id")
    private Integer companyId;

    /**
     * 最大并发
     */
    @TableField(value = "max_concurrent_num")
    private String maxConcurrentNum;

    @TableField(value = "trans_name")
    private String transName;

    @TableField(value = "trans_type")
    private String transType;

    @TableField(value = "name")
    private String name;

    @TableField(exist = false)
    private Integer isValid;


    public static CtiTask fromJson(JSONObject jsonObject) {
        CtiTask ctiTask = new CtiTask();
        ctiTask.setAiFlag(jsonObject.getString("ai_flag"));
        ctiTask.setRoName(jsonObject.getString("ro_name"));
        ctiTask.setTaskid(jsonObject.getString("taskid"));
        ctiTask.setTaskStatus(jsonObject.getString("task_status"));
        ctiTask.setLastBeginTime(jsonObject.getString("last_begin_time"));
        ctiTask.setCalledNumber(jsonObject.getString("called_number"));
        ctiTask.setTotCust(jsonObject.getString("tot_cust"));
        ctiTask.setTotCallsuc(jsonObject.getString("tot_callsuc"));
        ctiTask.setTotUncall(jsonObject.getString("tot_uncall"));
        ctiTask.setTotFailure(jsonObject.getString("tot_failure"));
        ctiTask.setTotSuccess(jsonObject.getString("tot_success"));
        ctiTask.setTotTocustomer(jsonObject.getString("tot_tocustomer"));
        ctiTask.setTotCallsucRate(jsonObject.getString("tot_callsuc_rate"));
        ctiTask.setTotUncallRate(jsonObject.getString("tot_uncall_rate"));
        ctiTask.setTotSuccessRate(jsonObject.getString("tot_success_rate"));
        ctiTask.setTotTocustomerRate(jsonObject.getString("tot_tocustomer_rate"));
        return ctiTask;
    }

    public JSONObject toJsonObject() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("taskid", this.getTaskid());
        jsonObject.put("taskStatus", "1");
        jsonObject.put("tel", "");
        jsonObject.put("transType", this.getTransType());
        jsonObject.put("max_concurrent_num", this.getMaxConcurrentNum());
        jsonObject.put("transName", this.getTransName());
        jsonObject.put("pstnNumber", this.getCalledNumber());
        return jsonObject;
    }


    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
}
